<?php
/**
 * 默认接口服务类
 *
 * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
 */

class Api_Dispatch extends PhalApi_Api {

	public function getRules() {
		return array(
			'listDispatch'=>array(
				'doctor_id'=>array('name'=>'DoctorId',),
				'event_id'=>array('name'=>'EventId',)
			),
			'listDoctorOfDispatch'=>array(
				'event_id'=>array('name'=>'EventId',),
				'lng'=>array('name'=>'Lng',),
				'lat'=>array('name'=>'Lat',)
			),
			'getDispatch'=>array(
				'dispatch_id'=>array('name'=>'DispatchId','require'=>true)
			)
		);
	}

	/**
	 * 派单信息列表
	 * @desc 派单信息列表
	 * @return int code 操作码，0表示成功， 1错误
	 * @return object info 信息对象
	 * @return string msg 提示信息
	 */
	public function listDispatch() {
		$rs = array('code' => 0, 'msg' => '', 'info' => array('a'=>1));

		$domain = new Domain_Dispatch();
		$info = $domain->listDispatch($this->doctor_id,$this->event_id);

		if (empty($info)) {
			DI()->logger->debug('listDispatch()','');

			$rs['code'] = 1;
			$rs['msg'] = T('暂时没有派单信息');
			return $rs;
		}

		$rs['info'] = $info;
		DI()->logger->debug('info of listDispatch()', $rs);

		return $rs;
	}

/**
	 * 派单信息列表
	 * @desc 派单信息列表
	 * @return int code 操作码，0表示成功， 1错误
	 * @return object info 信息对象
	 * @return string msg 提示信息
	 */
	public function listDoctorOfDispatch() {
		$rs = array('code' => 0, 'msg' => '', 'info' => array('a'=>1));

		$domain = new Domain_Dispatch();
		$info = $domain->listDoctorOfDispatch($this->event_id,$this->lng,$this->lat);

		if (empty($info)) {
			DI()->logger->debug('listDispatch()','');

			$rs['code'] = 1;
			$rs['msg'] = T('暂时没有派单信息');
			return $rs;
		}

		$rs['info'] = $info;
		//print_r($rs);
		DI()->logger->debug('info of listDispatch()', $rs);

		return $rs;

	}
	
	/**
	 * 派单详情
	 * @desc 获取派单详情
	 * @return int code 操作码，0表示成功， 1错误
	 * @return object info 信息对象
	 * @return string msg 提示信息
	 */
	public function getDispatch() {
		$rs = array('code' => 0, 'msg' => '', 'info' =>array('a'=>1));

		$domain = new Domain_Dispatch();
		$info = $domain->getDispatch($this->dispatch_id);

		if (empty($info)) {
			DI()->logger->debug('getDispatch()','');

			$rs['code'] = 1;
			$rs['msg'] = T('获取派单详情失败');
			return $rs;
		}

		$rs['info'] = $info;
		DI()->logger->debug('info of getDispatch()', $rs);

		return $rs;

	}
}